Change in openvpn[master]: Directly use _countof in array initialisation
A message that is not in the archive (sent off-list or not yet received): gerrit.1742822307000.Ib579c1538eb5440bb7008bc866a5cb7d74844374@...2715...
Attention is currently required from: flichtenheld.
Hello flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/915?usp=email
to review the following change.
Change subject: Directly use _countof in array initialisation
......................................................................
Directly use _countof in array initialisation
This fixes the build failures on MSVC cl compiler.
MSVC cl does not thinks of the expression of a const variable times an integer to be compile time static. C23 introduce the constexpr (like in C++) statement for that but we are only on C11 for now.
So directly use the _countof(msg->addr) expression in the array initialisation.
---
M src/openvpnserv/interactive.c
1 file changed, 4 insertions(+), 1 deletion(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/15/915/1
src/openvpnserv/interactive.c +4 -1
@@ -34,6 +34,7 @@#include <shellapi.h> #include <mstcpip.h> #include <inttypes.h> +#include <assert.h> #include <versionhelpers.h>
@@ -1901,7 +1902,9 @@if (msg->addr_len >0 ) {/* prepare the comma separated address list */ -CHAR addrs[max_addrs *64 ];/* 64 is enough for one IPv4/6 address */ +/* cannot use max_addrs here as that is not considered compile +* time constant by all compilers and constexpr is C23 */ +CHAR addrs[_countof (msg->addr) *64 ];/* 64 is enough for one IPv4/6 address */ size_t offset =0 ;for (int i =0 ; i < addr_len; ++i) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/915?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib579c1538eb5440bb7008bc866a5cb7d74844374
Gerrit-Change-Number: 915
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld.
Hello flichtenheld,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/915?usp=email
to look at the new patch set (#2).
Change subject: Directly use _countof in array initialisation
......................................................................
Directly use _countof in array initialisation
This fixes the build failures on MSVC cl compiler.
MSVC cl does not thinks of the expression of a const variable times an integer to be compile time static. C23 introduce the constexpr (like in C++) statement for that but we are only on C11 for now.
So directly use the _countof(msg->addr) expression in the array initialisation.
---
M src/openvpnserv/interactive.c
1 file changed, 3 insertions(+), 1 deletion(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/15/915/2
src/openvpnserv/interactive.c +3 -1
@@ -1901,7 +1901,9 @@if (msg->addr_len >0 ) {/* prepare the comma separated address list */ -CHAR addrs[max_addrs *64 ];/* 64 is enough for one IPv4/6 address */ +/* cannot use max_addrs here as that is not considered compile +* time constant by all compilers and constexpr is C23 */ +CHAR addrs[_countof (msg->addr) *64 ];/* 64 is enough for one IPv4/6 address */ size_t offset =0 ;for (int i =0 ; i < addr_len; ++i) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/915?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib579c1538eb5440bb7008bc866a5cb7d74844374
Gerrit-Change-Number: 915
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/915?usp=email )
Change subject: Directly use _countof in array initialisation
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/915?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib579c1538eb5440bb7008bc866a5cb7d74844374
Gerrit-Change-Number: 915
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Mon, 24 Mar 2025 13:32:07 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v2 1/1 Directly use _countof in array initialisation
In reply to a message not in the archiveFrom: Arne Schwabe <[email protected]...>
This fixes the build failures on MSVC cl compiler.
MSVC cl does not thinks of the expression of a const variable times an integer to be compile time static. C23 introduce the constexpr (like in C++) statement for that but we are only on C11 for now.
So directly use the _countof(msg->addr) expression in the array initialisation.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/915
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>
src/openvpnserv/interactive.c +3 -1
@@ -1901,7 +1901,9 @@if (msg->addr_len >0 ) {/* prepare the comma separated address list */ -CHAR addrs[max_addrs *64 ];/* 64 is enough for one IPv4/6 address */ +/* cannot use max_addrs here as that is not considered compile +* time constant by all compilers and constexpr is C23 */ +CHAR addrs[_countof (msg->addr) *64 ];/* 64 is enough for one IPv4/6 address */ size_t offset =0 ;for (int i =0 ; i < addr_len; ++i) {
[Openvpn-devel] [PATCH applied] Re: Directly use _countof in array initialisation
Thanks. Back to old-style const expressions, then...
Your patch has been applied to the master branch.
commit 1fc44d3b2ad3b96405650754a6e43f1576cda132
Author: Arne Schwabe Date: Mon Mar 24 14:37:53 2025 +0100
Directly use _countof in array initialisation
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Frank Lichtenheld <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31205.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#3) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/915?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld
Change subject: Directly use _countof in array initialisation
......................................................................
Directly use _countof in array initialisation
This fixes the build failures on MSVC cl compiler.
MSVC cl does not thinks of the expression of a const variable times an integer to be compile time static. C23 introduce the constexpr (like in C++) statement for that but we are only on C11 for now.
So directly use the _countof(msg->addr) expression in the array initialisation.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31205.html
---
M src/openvpnserv/interactive.c
1 file changed, 3 insertions(+), 1 deletion(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/15/915/3
src/openvpnserv/interactive.c +3 -1
@@ -1901,7 +1901,9 @@if (msg->addr_len >0 ) {/* prepare the comma separated address list */ -CHAR addrs[max_addrs *64 ];/* 64 is enough for one IPv4/6 address */ +/* cannot use max_addrs here as that is not considered compile +* time constant by all compilers and constexpr is C23 */ +CHAR addrs[_countof (msg->addr) *64 ];/* 64 is enough for one IPv4/6 address */ size_t offset =0 ;for (int i =0 ; i < addr_len; ++i) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/915?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib579c1538eb5440bb7008bc866a5cb7d74844374
Gerrit-Change-Number: 915
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/915?usp=email )
Change subject: Directly use _countof in array initialisation
......................................................................
Directly use _countof in array initialisation
This fixes the build failures on MSVC cl compiler.
MSVC cl does not thinks of the expression of a const variable times an integer to be compile time static. C23 introduce the constexpr (like in C++) statement for that but we are only on C11 for now.
So directly use the _countof(msg->addr) expression in the array initialisation.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31205.html
---
M src/openvpnserv/interactive.c
1 file changed, 3 insertions(+), 1 deletion(-)
src/openvpnserv/interactive.c +3 -1
@@ -1901,7 +1901,9 @@if (msg->addr_len >0 ) {/* prepare the comma separated address list */ -CHAR addrs[max_addrs *64 ];/* 64 is enough for one IPv4/6 address */ +/* cannot use max_addrs here as that is not considered compile +* time constant by all compilers and constexpr is C23 */ +CHAR addrs[_countof (msg->addr) *64 ];/* 64 is enough for one IPv4/6 address */ size_t offset =0 ;for (int i =0 ; i < addr_len; ++i) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/915?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib579c1538eb5440bb7008bc866a5cb7d74844374
Gerrit-Change-Number: 915
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged